// Lindsay Gilmour
// Adam Lusch
// Dan Niceswanger
//
// Computer Graphics Project 2:
// Teapot racing!

#ifndef TEAPOT_H
#define TEAPOT_H

#include <GL/glut.h>

#include <Box2D.h>

#include "Tire.h"
#include "util.h"

class Teapot
{
	public:
	
		enum Direction {LEFT = 0, RIGHT, STRAIGHT};
		enum Acceleration {FORWARD = 0, REVERSE, COAST};
		
		static const GLdouble STEERING_MIN;
		static const GLdouble STEERING_MAX;
		static const GLdouble STEERING_INCREMENT;
		
		static const GLdouble TIRE_FRONT_SPEED;
		static const GLdouble TIRE_REAR_SPEED;
		
		static const GLdouble NORMAL_ACCEL_AMOUNT;
		static const GLdouble NORMAL_BRAKE_AMOUNT;
	
		static void setup();
		static void cleanup();
	
		Teapot(b2World*, GLdouble, GLdouble, GLdouble);
		Teapot(const Teapot&);
		Teapot();
		virtual ~Teapot();

		void update();
		void draw(GLfloat = 1.0) const;
		void drawSimple(GLfloat = 1.0) const;
		
		GLdouble getX() const;
		GLdouble getZ() const;
		GLdouble getHeading() const;
		
		GLdouble getSpeed() const;
		
		void turn(Direction);
		void accelerate(Acceleration);
	
		void setColor(GLfloat, GLfloat, GLfloat, GLfloat);
		
	private:
		
		static GLuint baseList;
		static GLuint simpleList;
		
		GLfloat* color;
		
		Tire flTire, frTire, rlTire, rrTire;
		
		GLdouble turnAngle;
		
		GLdouble accelAmount;
		GLdouble brakeAmount;
		GLdouble coastAmount;
		
		Direction dir;
		Acceleration accel;
		
		int jumpCounter;
		float jumpHeight;
		int jumpSteps;

	protected:

		b2Body* body;
		b2World* world;
};

#endif
